package com.atguigu.gulimall.member.web;

import com.atguigu.common.utils.R;
import com.atguigu.gulimall.member.feign.OrderFeignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.HashMap;

/**
 * @Author : Jungle
 * @Description :
 */
@Controller
public class MemberWebController {
    @Autowired
    private OrderFeignService orderFeignService;
    @GetMapping("/memberOrder.html")
    public String  memberOrderPage(@RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum, Model model){
        //获取支付宝传来的所有请求数据
        //reques 验证签名，如果正确可以去修改

        //查出当前登录的用户的所有订单列表数据
        HashMap<String, Object> page = new HashMap<>();
        //当前页码,注意这个页码封装的方法为字符串
        page.put("page", pageNum.toString());
        R r = orderFeignService.listWithItem(page);
       //r.getData("page",new TypeReference<Order>())
       // System.out.println(JSON.toJSONString(r));
        model.addAttribute("orders", r);
        return "orderList";
    }
}
